<template>
	<view class="groupauditlist">
		<!-- <view class="title">入会审核管理</view> -->
		<view class="groupauditlist_top_block">
			<view class="groupauditlist_tabs">
				<view @click="changeTabs(-1)"
					:class="params.status==-1?'groupauditlist_tabs_cell tabs_on':'groupauditlist_tabs_cell'">全部</view>
				<view @click="changeTabs(0)"
					:class="params.status==0?'groupauditlist_tabs_cell tabs_on':'groupauditlist_tabs_cell'">待审核</view>
				<view @click="changeTabs(-2)"
					:class="params.exit_status==1?'groupauditlist_tabs_cell tabs_on':'groupauditlist_tabs_cell'">已退出
				</view>
			</view>
			<view class="groupauditlist_table_header" v-if="list.length>0">
				<uni-row gutter="8">
					<uni-col :span="4">
						<view class="text-c">ID</view>
					</uni-col>
					<uni-col :span="8">
						<view class="text-c">姓名</view>
					</uni-col>
					<uni-col :span="8">
						<view class="text-c">入会日期</view>
					</uni-col>
					<uni-col :span="4">
						<view class="text-c">状态</view>
					</uni-col>
				</uni-row>
			</view>
		</view>
		<view class="f-14 list">
			<view v-for="(item,index) in list" :key="item.id" class="groupaudit_cell" @click="goInfo(item.id)">
				<uni-row gutter="8">
					<uni-col :span="4">
						<view class="text-c">{{item.id}}</view>
					</uni-col>
					<uni-col :span="8">
						<view class="text-c ellipsis">{{item.name}}</view>
					</uni-col>
					<uni-col :span="8">
						<view class="text-c">{{item.join_time?item.join_time.substring(0,10):'无'}}</view>
					</uni-col>
					<uni-col :span="4">
						<view class="text-c green" v-if="item.status == 1">通过</view>
						<view class="text-c red" v-else-if="item.status == 0">待审核</view>
						<view class="text-c black" v-else>{{ item.exit_status == 1 ? '已退出' : '未通过' }}</view>
					</uni-col>
				</uni-row>
			</view>
			<view class="page_bottom_loading" :style="'padding-bottom:'+pdbottom+'rpx;'">{{loadingTitle}}</view>
		</view>
	</view>
</template>

<script>
	import {
		getGroupAuditList,
	} from '@/api/motortime.js';
	let app = getApp()
	export default {
		data() {
			return {
				params: {
					club_id: '',
					status: -1,
					exit_status: '',
					page: 1,
					size: 15,
				},
				list: [],
				loadingTitle: '',
				pdbottom: uni.getSystemInfoSync().safeAreaInsets.bottom ? uni.getSystemInfoSync().safeAreaInsets.bottom +
					60 : 60,
			};
		},
		onShow() {
			if (!uni.getStorageSync('access_token')) {
				uni.navigateTo({
					url: '/pages/login/login'
				})
			}
			if (uni.getStorageSync('userinfo').is_staff == 0) {
				uni.switchTab({
					url: '/pages/index/index'
				})
			}else{
				if (uni.getStorageSync('onload')) {
					this.params.page = 1
					this.list = []
					this.getGroupAuditList()
					uni.removeStorage({
						key: 'onload'
					})
				}
			}
		},
		onLoad(options) {
			if (uni.getStorageSync('userinfo').is_staff != 0) {
				this.club_id = options.club_id
				this.list = []
				this.params.club_id = options.club_id
				this.getGroupAuditList()
			}
			var params = {
				event_code: '入会审核管理',
				path: 'pages/groupmanage/groupauditlist',
				event_id: '',
				title: '',
				source_page: '',
				value: '',
			}
			app.BurialPoint(params)
		},
		methods: {
			getGroupAuditList() {
				getGroupAuditList(this.params).then(res => {
					if (res.state == 1) {
						this.list = [...this.list, ...res.data.data]
						this.current_page = res.data.current_page
						this.last_page = res.data.last_page
						if (this.list.length == 0) {
							this.loadingTitle = "- 暂无更多 -"
						}
					} else {
						uni.showToast({
							title: res.error[0],
							mask: true,
							icon: 'none',
							duration: 1500
						})
					}
				})
			},

			changeTabs(index) {
				if (index == -2) {
					this.params.status = 2
					this.params.exit_status = 1
				} else {
					this.params.status = index
					this.params.exit_status = ''
				}
				this.params.page = 1
				this.list = []
				this.getGroupAuditList()
			},
			goInfo(id) {
				uni.navigateTo({
					url: '/pages/groupmanage/groupauditinfo?id=' + id + '&club_id=' + this.club_id
				})
			}
		},
		onPullDownRefresh() {
			this.params.page = 1
			this.list = []
			this.getGroupAuditList()
			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			if (this.current_page < this.last_page) {
				this.showLoading = true
				this.params.page = this.params.page + 1
				this.getGroupAuditList()
			} else {
				this.showLoading = false
				if (this.list.length > 0) {
					this.loadingTitle = "- 已经到底了 -"
				} else {
					this.loadingTitle = "- 暂无更多 -"
				}

			}
		}
	}
</script>

<style lang="scss">
	.groupauditlist {
		padding: 0 30rpx 50rpx 30rpx;

		.title {
			font-size: 32rpx;
			color: #000000;
		}

		.groupauditlist_top_block {
			padding-top: 30rpx;
			position: sticky;
			top: 0;
			z-index: 1;
			background-color: #ffffff;

			.groupauditlist_tabs {
				height: 80rpx;
				font-size: 30rpx;
				display: flex;
				align-items: center;
				justify-content: space-around;
				border-radius: 8rpx;
				border: 2rpx solid #E9E9E9;

				.groupauditlist_tabs_cell {
					width: 25%;
					height: 30rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					border-right: 4rpx solid #000000;
				}

				.groupauditlist_tabs_cell:last-child {
					border-right: 0;
				}

				.tabs_on {
					color: #00A0DC;
				}
			}

			.groupauditlist_table_header {
				font-size: 26rpx;
				margin: 40rpx 0 30rpx 0;
				padding: 28rpx 0;
				border-radius: 8rpx;
				background-color: #F2F2F2;
			}
		}

		.list {
			margin-top: 20rpx;

			.groupaudit_cell {
				margin-bottom: 20rpx;
				border-radius: 8rpx;
				background-color: #F7F7F7;
				height: 80rpx;
				line-height: 80rpx;

				.green {
					color: #07C061;
				}

				.red {
					color: #EE2A2A;
				}

				.black {
					color: #666666;
				}

				.status .img {
					width: 110rpx;
					height: 30rpx;
				}

				.info {
					padding: 30rpx;
					overflow: hidden;

					.content {
						font-size: 28rpx;
						color: #000000;
						margin-bottom: 20rpx;

						.label {
							color: #666;
							padding-right: 20rpx;
						}
					}

					.link {
						display: inline-block;
						float: right;
					}
				}
			}
		}
	}
</style>